import { IFolder } from "@/components/Library/index";
import { Commit } from "vuex/types/index";
const LibraryStore = {
  state: {
    sortByValue: "modifiedDate",
    sortDescValue: false,
    folderList: [],
    loadingFolderList: false,
  },
  mutations: {
    setSortByValue(state: { sortByValue: string }, sortByValue: string) {
      state.sortByValue = sortByValue;
    },
    setSortDescValue(
      state: { sortDescValue: boolean },
      sortDescValue: boolean
    ) {
      state.sortDescValue = sortDescValue;
    },
    setFolderList(state: { folderList: IFolder[] }, folderList: IFolder[]) {
      state.folderList = folderList;
    },
  },
  actions: {
    refreshFolderList(context: {
      commit: Commit;
      state: { loadingFolderList: boolean };
    }) {
      context.state.loadingFolderList = true;
      const folderList = [
        {
          id: "1",
          type: "Folder",
          name: "Application",
          size: "12.4MB",
          fileLocation: "",
          modifiedDate: "December 5, 2022 18:22:05",
          fileList: [
            {
              id: "4",
              type: "Video",
              name: "Zew Microsoft Excel Worksheet.video",
              modifiedDate: "2021-10-17 10:23",
              size: "11,659.651 KB",
            },
            {
              id: "5",
              type: "Pptx",
              name: "Sew Microsoft PowerPoint Presentation.pptx",
              modifiedDate: "2021-10-15 12:24",
              size: "6.054 KB",
            },
            {
              id: "6",
              type: "Docx",
              name: "New Microsoft Word Document.docx",
              modifiedDate: "2021-10-13 12:21",
              size: "38 KB",
            },
            {
              id: "7",
              type: "Pdf",
              name: "Zew Microsoft PDF.pdf",
              modifiedDate: "2021-10-19 10:23",
              size: "24.8 KB",
            },
            {
              id: "8",
              type: "Pub",
              name: "Aew Microsoft Publisher Document.pub",
              modifiedDate: "2021-10-17 10:23",
              size: "218.099 KB",
            },
            {
              id: "9",
              type: "Jpg",
              name: "New Microsoft Excel Worksheet.jpg",
              modifiedDate: "2021-10-17 11:23",
              size: "58.3 KB",
            },
            {
              id: "10",
              type: "Rar",
              name: "New WinRAR archive.rar",
              modifiedDate: "2021-10-18 10:23",
              size: "9 KB",
            },
            {
              id: "11",
              type: "Zip",
              name: "New WinRAR ZIP archive.zip",
              modifiedDate: "2021-10-19 10:23",
              size: "0.021 KB",
            },
            {
              id: "12",
              type: "Txt",
              name: "New Text Document.txt",
              modifiedDate: "2021-10-18 10:23",
              size: "11,659.651 KB",
            },
            {
              id: "14",
              type: "Xlsx",
              name: "New Microsoft Excel Worksheet.xlsx",
              modifiedDate: "2021-10-17 10:23",
              size: "32 KB",
            },
            {
              id: "13",
              type: "Xlsx",
              name: "New Microsoft Excel Worksheet.xlsx",
              modifiedDate: "2021-10-17 11:23",
              size: "32 KB",
            },
          ],
          children: [
            {
              id: "2",
              type: "Folder",
              name: "Demo",
              size: "11.38MB",
              fileLocation: "",
              modifiedDate: "December 5, 2022 19:16:53",
              fileList: [
                {
                  id: "4",
                  type: "video",
                  name: "New Microsoft Excel Worksheet.video",
                  modifiedDate: "2021-10-17 10:23",
                  size: "11,659.651 KB",
                },
              ],
            },
            {
              id: "3",
              type: "Folder",
              name: "Demo 1",
              size: "0MB",
              fileLocation: "",
              modifiedDate: "December 5, 2022 19:32:21",
              fileList: [],
            },
          ],
        },
      ];
      setTimeout(() => {
        context.commit("setFolderList", folderList);
        context.state.loadingFolderList = false;
      }, 1500);
    },
  },
};

export { LibraryStore };
